<template>
    <div id="app">
<!--        <el-container>-->
<!--            <el-header style="height: 80px">-->
<!--                <Header></Header>-->
<!--            </el-header>-->
<!--            <el-container v-if="this.$store.state.mode === 'graph'" class="bottom-container">-->
<!--                &lt;!&ndash;        侧边栏&ndash;&gt;-->
<!--                <el-aside style="height: 100%">-->
<!--                    <Side></Side>-->
<!--                </el-aside>-->
<!--                &lt;!&ndash;        图谱展示主题&ndash;&gt;-->
<!--                <el-main style="height: 100%">-->
<!--                    <ToolBar style="height: 5%"></ToolBar>-->
<!--                    <router-view style="height: 95%"></router-view>-->
<!--                </el-main>-->
<!--            </el-container>-->
<!--            <el-container v-else-if="this.$store.state.mode === 'analysis'">-->
<!--                <RouterView style="width: 100%; height: 100%"></RouterView>-->
<!--            </el-container>-->
<!--            <el-container v-else-if="this.$store.state.mode === 'stock'">-->
<!--                <RouterView style="width: 100%; height: 100%"></RouterView>-->
<!--            </el-container>-->
<!--        </el-container>-->
        <RouterView></RouterView>
    </div>
</template>

<script>
import Header from '@/components/Layout/Header.vue';
import Side from '@/components/Layout/Side.vue';
import ToolBar from '@/components/Layout/ToolBar.vue';
import {getUserInfo} from "@/api/user";
export default {
    data() {
        return {
            style: false
        };
    },
    components: {
        ToolBar,
        Side,
        Header
    },
    async beforeCreate() {
       //  检测有无token
       let token= window.localStorage.getItem("token")
        if (token === ""){
            this.$router.push("/login")
            return
        }else {
            console.log("有效")
            // 根据token获取用户信息
            await getUserInfo({accessToken:token}).then((response)=>{
                if (response.data.code !== 200){
                    this.$router.push("/login")
                    return
                }else {
                    let data= response.data.data
                    this.$store.commit("setUserInfoAvatar",data.avatar)
                    this.$store.commit("setUserInfoUsername",data.username)
                    this.$router.push("/g/twodgraph")
                }
            })
        }
    }
};
</script>

<style>
.scene-container {
    width: 100%;
    height: 100%;
}
#app {
    height: 100%;
}
.el-container {
    width: 100%;
    height: 100%;
}
.el-header {
    height: 90px;
    padding: 0;
}
.bottom-container {
    width: 96%;
    margin: 0 auto;
}
.el-side {
    max-height: 900px;
}

</style>
